<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>列表渲染</title>
    <script src="../js/vue.js"></script>
    <style>

    </style>
</head>

<body>
    <div id="root">
        <h2>遍历数组</h2>
        <ul>
            <li v-for="(p,index) of persons" :key="p.id">{{p.name}}-{{p.age}}</li>
        </ul>

        <h2>遍历对象</h2>
        <ul>
            <li v-for="(p,index) of car" :key="index">{{index}}-{{p}}</li>
        </ul>
        <h2>遍历字符串</h2>
        <ul>
            <li v-for="(p,index) of str" :key="index">{{index}}-{{p}}</li>
        </ul>
    </div>
    <script>
        Vue.config.productionTip = false

        const vm = new Vue({
            el: '#root',
            data: {
                persons: [
                    {
                        id: 1,
                        name: '张三',
                        age: 18
                    },
                    {
                        id: 2,
                        name: '李四',
                        age: 19
                    }, {
                        id: 3,
                        name: '王五',
                        age: 20
                    }]
                , car: {
                    name: '奥迪',
                    color: 'red',
                    size: 12
                },
                str: 'hello'
            }
        })
    </script>
</body>

</html>